package ddpserverui;

import javax.swing.*;
import com.seaglasslookandfeel.*;
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

import javax.swing.BorderFactory;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.ImageIcon;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.Box;
import javax.swing.BoxLayout;

@SuppressWarnings("unused")
public class ServerUI extends JPanel {
	/**
	 * This is the serial ID for ddpServer
	 */
	private static final long serialVersionUID = 1L;

	public ServerUI() throws InvocationTargetException, InterruptedException{
		try {
			UIManager
					.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
		} catch (Exception e) {
			e.printStackTrace();
		}
		javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
			public void run() {
				createAndShowGUI();
			}
		});
	}

	public static void createAndShowGUI() {
		JFrame frame = new JFrame("ddpServer");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(900,400);
        
		//exit the program when shut down the window, may duplicate setDefaultCloseOperation?
		frame.addWindowListener(new java.awt.event.WindowAdapter() {
			public void windowClosing(java.awt.event.WindowEvent evt) {
				System.exit(0);
			}
		});
		
		//add the console text area
		ConsoleTextArea consoleTextArea = null;
		try {
			consoleTextArea = new ConsoleTextArea();
		} catch (IOException e) {
			System.err.println("Fail to create console text area." + e);
			System.exit(1);
		}

		frame.getContentPane().add(new JScrollPane(consoleTextArea),
				java.awt.BorderLayout.CENTER);
		frame.setBounds(400, 250, 500, 500);
	    
		JPanel panel = new JPanel();
		panel.setBorder(BorderFactory.createEmptyBorder(20,20,20,20)); 
		JButton b1=new JButton("Start");
		panel.add(b1);
        frame.add(panel);
		
		frame.setLayout(new GridLayout(2,1));
		// display the window
		frame.setVisible(true);
	}
	
	public static void main(String[] args) throws InterruptedException, // for unit test
	InvocationTargetException {
		try {
			UIManager
			.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
		} catch (Exception e) {
			e.printStackTrace();
		}
		javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
			public void run() {
				createAndShowGUI();
			}
		});
	}
}
